//
//  HouseDetailHeaderView.m
//  YJRenter
//
//  Created by 文彬 on 2018/7/2.
//  Copyright © 2018年 文彬. All rights reserved.
//

#import "HouseDetailHeaderView.h"
#import "WBLoopScrollView.h"

@interface HouseDetailHeaderView()<WBLoopScrollViewDelegate>

@property (strong, nonatomic) WBLoopScrollView *loopScrollView;
@property (strong, nonatomic) UILabel *titleLabel;
@property (strong, nonatomic) UILabel *tagLabel;

@end

@implementation HouseDetailHeaderView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self initControl];
    }
    
    return self;
}

- (void)initControl{
    self.backgroundColor = kPageBackgroundColor;
    [self addSubview:self.loopScrollView];
    [self.loopScrollView layoutPages];
    
    UIView *bottomView = [[UIView alloc]init];
    bottomView.backgroundColor = [UIColor whiteColor];
    [self addSubview:bottomView];
    [bottomView makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@15);
        make.right.equalTo(@-15);
        make.bottom.equalTo(@0);
        make.height.equalTo(@80);
    }];
    
    [bottomView addSubview:self.titleLabel];
    self.titleLabel.text = @"大亚湾精品海景房间";
    [self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@10);
        make.right.equalTo(@-10);
        make.height.equalTo(@30);
        make.top.equalTo(@10);
    }];
    
    [bottomView addSubview:self.tagLabel];
    self.tagLabel.text = @"意厨 · 优品 · 意居门锁 · 速订 · 验真";
    [self.tagLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@10);
        make.right.equalTo(@-10);
        make.height.equalTo(@30);
        make.bottom.equalTo(@-10);
    }];
}

#pragma mark WBLoopScrollViewDelegate
//总共的页数
- (NSInteger)numOfTotalPageCount
{
    return 1;
}

//单个页面的布局
- (UIView*)viewForPageIndex:(NSInteger)index
{
    UIImageView *view = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.loopScrollView.frame.size.width, self.loopScrollView.frame.size.height)];
    view.backgroundColor = [UIColor lightGrayColor];
    [view sd_setImageWithURL:[NSURL URLWithString:@"https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=4036889747,3526425271&fm=27&gp=0.jpg"] placeholderImage:nil options:SDWebImageRetryFailed];
    return view;
}
#pragma mark getter
- (WBLoopScrollView*)loopScrollView{
    if (_loopScrollView==nil) {
        _loopScrollView  = [[WBLoopScrollView alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height-70) animationDuration:5];
        _loopScrollView.delegate = self;
    }
    return _loopScrollView;
}

- (UILabel*)titleLabel{
    if (_titleLabel==nil) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.font = [UIFont systemFontOfSize:18];
        _titleLabel.textColor = [UIColor blackColor];
    }
    
    return _titleLabel;
}

- (UILabel*)tagLabel{
    if (_tagLabel==nil) {
        _tagLabel = [[UILabel alloc]init];
        _tagLabel.font = [UIFont systemFontOfSize:15];
        _tagLabel.textColor = kSecTitleColor;
    }
    
    return _tagLabel;
}
@end
